import service.UserService;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2024/12/05
 * @description 静态代理，自定义的代理类
 */
public class StaticProxy implements UserService {
    // 关联关系
    private UserService target;

    public StaticProxy(UserService target) {
        this.target = target;
    }

    @Override
    public void deleteUser() {
        long begin = System.currentTimeMillis();
        target.deleteUser();
        long end = System.currentTimeMillis();
        System.out.println("耗时：" + (end - begin) + "毫秒");
    }

    @Override
    public void updateUser() {
        long begin = System.currentTimeMillis();
        target.updateUser();
        long end = System.currentTimeMillis();
        System.out.println("耗时：" + (end - begin) + "毫秒");
    }
}
